/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datatools;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author SIDALI
 */
public class emf {

    private static String PERSISTENCE_UNIT_NAME = "mandatairePU";

    /**
     * @return the PERSISTENCE_UNIT_NAME
     */
    public static String getPERSISTENCE_UNIT_NAME() {
        return PERSISTENCE_UNIT_NAME;
    }

    /**
     * @param aPERSISTENCE_UNIT_NAME the PERSISTENCE_UNIT_NAME to set
     */
    public static void setPERSISTENCE_UNIT_NAME(String aPERSISTENCE_UNIT_NAME) {
        PERSISTENCE_UNIT_NAME = aPERSISTENCE_UNIT_NAME;
    }
    private EntityManagerFactory factory;
    private EntityManager em ;

    private emf() {
        factory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
        em = factory.createEntityManager();
    }

    public static emf getInstance() {
        return emfHolder.INSTANCE;
    }

    /**
     * @return the factory
     */
    public EntityManagerFactory getFactory() {
        return factory;
    }

    /**
     * @param factory the factory to set
     */
    public void setFactory(EntityManagerFactory factory) {
        this.factory = factory;
    }

    /**
     * @return the em
     */
    public EntityManager getEm() {
        return em;
    }

    /**
     * @param em the em to set
     */
    public void setEm(EntityManager em) {
        this.em = em;
    }

    private static class emfHolder {

        private static final emf INSTANCE = new emf();
    }
}
